package com.ctgu.server.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ctgu.server.dao.dto.GroupRoleDto;
import com.ctgu.server.dao.entity.GroupRole;
import com.ctgu.server.dao.vo.Result;
import com.ctgu.server.mapper.GroupRoleMapper;
import com.ctgu.server.service.GroupRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ctgu.server.utils.ResultUtil;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ctgu
 * @since 2023-05-30
 */
@Service
public class GroupRoleServiceImpl extends ServiceImpl<GroupRoleMapper, GroupRole> implements GroupRoleService {

    @Override
    public Result insertGroupRole(String groupId, String identify) {
        //判断当前用户身份
        //判断是否身份组重复
        //添加身份组
        GroupRole groupRole=new GroupRole();
        groupRole.setIdentify(identify);
        groupRole.setGroupId(groupId);
        this.save(groupRole);
        return ResultUtil.success();

    }

    @Override
    public Result updateGroupRole(GroupRoleDto groupRoleDto) {
        //判断当前用户身份
        //判断是否身份组重复
        //修改身份组

        GroupRole groupRole= this.getById(groupRoleDto.getId());
        groupRole.setIdentify(groupRoleDto.getIdentify());
        this.updateById(groupRole);
        return ResultUtil.success("修改成功");
    }
}
